<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
</head>

<body>
    <header class="aui-bar aui-bar-nav" style="background-color: #03a9f4;position:fixed;" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            异常响应
        </div>
    </header>
    <div class="aui-content aui-margin-b-15" style="margin-top:50px;">
        <ul class="aui-list aui-form-list">
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">异常类型</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="exceptionTypeName" disabled="true">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">产线编码</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="lineCode" disabled="true">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">工位编码</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="opCode" disabled="true">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">设备编码</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="equipCode" disabled="true">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">物料编码</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="mrlCode" disabled="true">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">异常内容</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="exceptionContentName" disabled="true">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">异常描述</div>
                    <div class="aui-list-item-input">
                        <textarea id="exceptionRemark" disabled="true"></textarea>
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">备注</div>
                    <div class="aui-list-item-input">
                        <textarea id="remark"></textarea>
                    </div>
                </div>
            </li>
        </ul>
        <p></p>
        <p></p>
        <div class="aui-btn aui-btn-info aui-btn-block" onclick="save()">响应</div>
        <p></p>
        <div class="aui-btn aui-btn-info aui-btn-block" onclick="lookImg()" style="margin-top:10px">查看图片</div>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript">
    //异常记录ID
    var billId = "";
    //任务id
    var taskId = "";

    //初始化查询仓库下拉框
    apiready = function() {

        reset();

        billId = api.pageParam.sysid;
        taskId = api.pageParam.taskId;

        $("#exceptionTypeName").val(api.pageParam.exceptionTypeName);
        $("#opCode").val(api.pageParam.opCode);
        $("#mrlCode").val(api.pageParam.mrlCode);
        $("#exceptionContentName").val(api.pageParam.exceptionContentName);
        $("#exceptionRemark").val(api.pageParam.exceptionRemark);
        $("#equipCode").val(api.pageParam.equipCode);
        $("#lineCode").val(api.pageParam.lineCode);
    }

    //清空表单数据
    function reset() {
        billId = "";
        taskId = "";
        $("#exceptionTypeName").val("");
        $("#opCode").val("");
        $("#mrlCode").val("");
        $("#exceptionContentName").val("");
        $("#exceptionRemark").val("");
        $("#remark").val("");
    }

    //异常响应保存
    function save() {
        //备注
        var remark = $("#remark").val();

        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/usmExceptionResponse";
        var data = {
            values: {
                billId: billId,
                taskId: taskId,
                remark: remark,
                mode: "response",
                un: un,
            }
        };
        api.showProgress({
            title: '异常响应中...',
        });
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function(ret, err) {
            if (ret) {
                api.hideProgress();
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                if (myobj.code == '0') {

                    api.toast({
                        msg: "异常响应成功",
                        duration: 3000
                    });
                    //返回上一菜单
                    closeWin();

                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            } else {
                api.hideProgress();
                alert(JSON.stringify(err));
            }
        });
    }

    //查看图片
    function lookImg() {
        //打开页面
        api.openWin({
            name: 'usmExceptionImgList',
            url: 'usmExceptionImgList.html',
            pageParam: {
                billId: billId,
            }
        });
    }

    //返回按钮
    function closeWin() {
        api.closeWin();
        api.execScript({
            name: "usmExceptionTask",
            script: 'doSearch()'
        });
    }
</script>

</html>
